<template>
  <div class="UploadLoad justifyAlignB">
    <el-dialog  v-dialogDrag   title="附件正在上传中" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
      <div v-if="api !== 'getProgressSalary'" style="display: flex; align-items: center"><h4 class="justifyAlign">当前上传银行</h4><b>:</b>{{ params.salaCardBank | getbankFilter(that) }}</div>
      <div style="display: flex; align-items: center"><h4 class="justifyAlign">当前上传单位数</h4><b>:</b>{{ object && object.agencyCount ? object.agencyCount : '' }}</div>
      <div style="display: flex; align-items: center"><h4 class="justifyAlign">人数</h4><b>:</b>{{ object && object.personCount ? object.personCount : '' }}</div>
      <div style="display: flex; align-items: center"><h4 class="justifyAlign">当前上传金额</h4><b>:</b>{{ object && object.sumRealSalary ? Number(object.sumRealSalary).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,") : '' }}</div>
      <el-progress :percentage="num" />
    </el-dialog>
  </div>
</template>

<script>
// import { getProgress, getProgressSalary } from '@/api/generateSalaryData/generateBankData'
export default {
  name: 'UploadLoad',
  components: {},
  filters: {
    getbankFilter(value, that) {
      for (const key in that.agencyBankLists) {
        if (that.agencyBankLists[key].code == value) {
          return that.agencyBankLists[key].name
        }
      }
    }
  },
  props: {
    api: {
      type: String,
      default: function() {
        return ''
      }
    },
    params: {
      type: Object,
      default: function() {
        return {}
      }
    },
     object: {
      type: Object,
      default: function() {
        return {}
      }
    },
    agencyBankLists: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },
  data() {
    return {
      that: this,
      dialogVisible: true,
      num: 0,
      timer: null,
      // object: {},
      success: false
    }
  },
  mounted() {
   // this.getProgresss()
    this.timer = setInterval(this.getNum, 500)
  },
  beforeDestroy() {
    clearInterval(this.timer)
  },
  methods: {
    // 接口返回成功,100
    getSuccessNum() {
      this.success = true
    },
    // getProgresss() {
    //   if (this.api === 'getProgress') {
    //     getProgress(this.params).then(res => {
    //       this.object = res.data[0]
          
    //     })
    //   }
    //   if (this.api === 'getProgressSalary') {
    //     getProgressSalary(this.params).then(res => {
    //       this.object = res.data[0]
        
    //     })
    //   }
    // },
    getNum() {
      if (this.success && this.num === 100) {
        clearInterval(this.timer)
        this.$emit('close', 1)
      }
      if (this.num < 90) {
        this.num = this.num + 10
      }
      if (this.num === 90 && this.success) {
        this.num = this.num + 10
      }
    },
    handleClose() {
      this.$emit('close', 1)
    }
  }
}
</script>
<style lang="scss">
  // .UploadLoad{}
</style>
